<template>
  <div id="wisdomPark-section-v1">
    <MyCell>
      <div class="content">
        <div class="content-item" v-for="i in wisdomPark_data" :key="i">
          <MyHeadline :title="i.title1" :islink="false" style="padding-left: 0px" />
          <div class="item">
            <div class="title">{{ i.title2 }}</div>
            <div class="value">{{ i.value }}</div>
          </div>
        </div>
      </div>
    </MyCell>
  </div>
</template>

<script setup lang="ts">
import { ref, onMounted, provide } from 'vue'
import { deepCopy } from '@/utils/utils'
import MyCell from '@/components/my-cell/index.vue'
import MyHeadline from '@/components/my-headline/index.vue'

import echartsConfig from '../config/wisdomPark-section-v1/echarts-config'
// ========================= 实例

// ========================= 钩子
onMounted(() => {
  echarts_init()
})

// ========================= 数据
// 数据
const wisdomPark_data = ref<any>([
  {
    title1: '人流监测',
    title2: '今日游客数',
    value: 0
  },
  {
    title1: '车流监测',
    title2: '今日车辆数',
    value: 0
  }
])

// ========================= 函数
// 初始化
const echarts_init = () => {
  onEcharts_data()
}

// 随机数
const getRandomInt = (min: number, max: number): number => {
  min = Math.ceil(min)
  max = Math.floor(max)
  return Math.floor(Math.random() * (max - min + 1)) + min
}

// 数据
const onEcharts_data = () => {
  for (const item of wisdomPark_data.value) {
    item.value = getRandomInt(0, 200000)
  }
}

// ========================= 请求

defineExpose({
  echarts_init
})
</script>

<style scoped lang="less">
#wisdomPark-section-v1 {
  .width_height(100%,100%);
  .content {
    .width_height(100%,100%);
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    box-sizing: border-box;
    padding: 0 @space_20;
    .content-item {
      width: calc(100% / 2 - @space_20 / 2);
      .item {
        .width_height(100%,76px);
        .D_F_J(column,center);
        background-image: linear-gradient(to right, #adcaaa83, #31c1d15b);
        border-radius: 4px;
        .title {
          .D_J_A(center,center);
          .font-S-W-C(14px,400,#fff);
          margin-bottom: 10px;
        }

        .value {
          .font-S-W-C(20px,700,#fff);
          .D_J_A(center,center);
        }
      }
    }
  }
}
</style>
